﻿var chatHub = $.connection.chatHub;

//setup the handler on the clientside for when the 
//method below is being invoked on the server
chatHub.client.writeMessage = function (message) {
    $("#messagesPool").append("<li>" + message + "</li>");
}

//Only wire up click event when we connect to server
$.connection.hub.start().done(function () {
    $("#sendButton").click(function () {

        //calling the method in the server to broadcast 
        //message to all connected clients
        chatHub.server.broadcastMessage($("#message").val());
    });
});